# Copyright 2017 Daniel 'grindhold' Brendle
#
# This file is part of parceldude.
#
# parceldude is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation, either
# version 3 of the License, or (at your option) any later
# version.
#
# parceldude is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with parceldude.
# If not, see http://www.gnu.org/licenses/.

project ('parceldude', 'vala', 'c')

pkgconfig = import('pkgconfig')
gnome = import('gnome')
if (host_machine.system() == 'windows')
    windows = import('windows')
endif

dep_glib = dependency('glib-2.0')
dep_gtk = dependency('gtk+-3.0')
dep_libmsi = dependency('libmsi-1.0', required: false)

valaflag = []
linkflag = []

if (host_machine.system() == 'windows')
    valaflag = ['--define=WIN32']
    linkflag = ['-mwindows']
endif

if dep_libmsi.found()
    valaflag += ['--define=HAS_LIBMSI']
endif

parceldude_app_dep = [dep_glib, dep_gtk, dep_libmsi]

if (host_machine.system() == 'windows')
    parceldude_winres = windows.compile_resources(
                        meson.current_source_dir()+'/data/parceldude.rc'
    )
else
    parceldude_winres = []
endif

parceldude_resources = gnome.compile_resources(
                        'parceldude-resources',
                        meson.current_source_dir()+'/data/de.grindhold.parceldude.gresource.xml',
                        source_dir: 'data')

#TODO: make icon creation via icotools part of this build
#      icotools -c -o data/icons/parceldude.ico `find data/icons -name "*.png"`

parceldude_app_src = [
    'src/about.vala',
    'src/donationview.vala',
    'src/feature.vala',
    'src/installer.vala',
    'src/installview.vala',
    'src/list.vala',
    'src/main.vala',
    'src/parameter.vala',
]

parceldude_app = executable('parceldude', parceldude_app_src, parceldude_resources, parceldude_winres,
                    dependencies: parceldude_app_dep,
                    install:true,
                    vala_args: ['--target-glib=2.38'] + valaflag,
	            link_args: linkflag)

